Ext.namespace("yft.posSupplyChannel");
var posSupplyChannelListStore_1 = new Ext.data.JsonStore({
		url:basepath+"/yft/posSupplyChannel/getPosSupplyChannelList.html",
		root:'root',
		totalProperty:'totalProperty',  
		fields:[
				{name: 'id'},
				{name: 'name'},
				{name: 'desc'}
		]
	});	
function addPosSupplyChannel(){
	var btnOk =new Ext.Button({
		minWidth:70,
		text:"确定",
		handler: submitPanel
	});
	var btnClear=new Ext.Button({
		minWidth:70,
		text:"清空",
		handler: clearPanel
	});
	var btnClose=new Ext.Button({
		minWidth:70,
		text:"关闭",
		handler: closeWin
	});

	var contSubmitPanel =new Ext.form.FormPanel({
		frame : true,
		defaults:{labelWidth:60,labelAlign:"right"},
		buttonAlign:'center',
		items:[{
			xtype : 'fieldset',
			 autoHeight : true,
			 items:[{
				 		layout : 'form',
						border : false,
						columnWidth : .5,
						items:[
							{height:8},
								{
									xtype:'textfield',
									name : 'name',
									fieldLabel : '业务类型名',
                                    maxLength:20,
                                    maxLengthText:'文字长度在20以内',
									labelStyle:labelStyle+" width:80",
									allowBlank : false,
									blankText : '业务类型名为必填项',
									width : 160,
									style:'float:left;padding-left:0px;'
								},
								{
									xtype:'textfield',
									name : 'desc',
									fieldLabel : '备注',
                                    maxLength:30,
                                    maxLengthText:'文字长度在30以内',
									labelStyle:" width:80",
									width : 160,
									style:'float:left;padding-left:0px;'
								}
						]
			 }]
		}],
		buttons:[btnOk,btnClear,btnClose]
	});
	var win =new Ext.Window({
		title:'业务类型添加',
		width: 320,
		items: contSubmitPanel,
		maskDisabled:true,
        id:'1231',
		resizable:false,
        closeAction:'close',
		autoScroll: false,
		draggable:true,
		modal: true,
		bodyStyle: my_scroll_cs
	});
	win.show();
	function submitPanel(){
        btnOk.setDisabled(true);
		if(contSubmitPanel.form.isValid()){
			contSubmitPanel.form.submit({
				waitTitle : '请稍候',
				waitMsg : '正在保存......',
				url :basepath+"/yft/posSupplyChannel/addPosSupplyChannel.html",
				success : function(form, action) {
					Ext.MessageBox.alert("系统消息", '恭喜您！操作已成功！', function(btn) {
						if(btn =='ok'){
							posSupplyChannelListStore_1.reload();
							win.close();
						}
					}, this);
				},
				failure : function(form, action) {
					submitButtonXsl.setDisabled(false);
					var m =Ext.decode(action.response.responseText);
					Ext.MessageBox.alert("错误",m.error);
				},
				scope : this
			});
		}else{
            btnOk.setDisabled(false);
		}
	}
	function clearPanel(){
		contSubmitPanel.form.reset();
	}
	function closeWin(){
		win.close();
	}
}

function posSupplyChannelSearch_1(){
	var query = Ext.util.Format.trim(Ext.getCmp('se_name').getValue());
	posSupplyChannelListStore_1.baseParams['query'] = query;
	posSupplyChannelListStore_1.removeAll();
	posSupplyChannelListStore_1.load({params:{start: 0,limit: colNum1}});
}

yft.posSupplyChannel.posSupplyChannelListPanel =Ext.extend(Ext.Panel, {
	anthArray:'',
	closable : true,
	autoScroll : true,
	width:'auto',
	layout : "fit",
	gridViewConfig : {
		animate : true
	},
	maskDisabled : false,
	bodyStyle:my_scroll_cs,
	initComponent : function() {
		yft.posSupplyChannel.posSupplyChannelListPanel.superclass.initComponent.call(this);
		var col =[
			{header:'渠道名',dataIndex:"name",sortable:true,align:'center',width: 100},
			{header:'备注',dataIndex:"desc",sortable:true,align:'center',width:120}
		];
		
		var toolBar =[
			'-',
			{
				text : '添加',
				iconCls : 'add',
				handler : addPosSupplyChannel,
				scope : this
			},'-',
			new Ext.Toolbar.Fill(),
			'名称:&nbsp;',
			{
				xtype : 'textfield',
				id : 'se_name',
				width : 90
			},'&nbsp;','-',{
				text : '查询',
//				iconCls : 'search',
				pressed : false,
				handler : posSupplyChannelSearch_1,
				scope : this
			},'-'
		];
		var posSupplyChannelListGridPanel_1 = new Ext.grid.GridPanel({
			store : posSupplyChannelListStore_1,
			columns : col,
			//clicksToEdit:1, 
			//autoExpandColumn : 7,
			pageSize : colNum1,
			myRightclickMenu: [
			],
			loadMask : new Ext.LoadMask(Ext.getBody(),{msg:"数据加载中..."}),
			tbar :toolBar,
			bbar : new Ext.PagingToolbar({
				pageSize : colNum1,
				store : posSupplyChannelListStore_1,
				displayInfo:true,
				displayMsg:'<span>显示第<span style="color:green;font-size:12px;font-weight:bold;">{0}</span>条到第<span style="color:blue;font-size:12px;font-weight:bold;">{1}</span>条记录，一共<span style="font-weight:bold;color:red;font-size:12px">{2}</span>条记录</a>',
				emptyMsg:'<span style="color:red">没有查询到相关信息<span>'
			})
		});
		posSupplyChannelListStore_1.load({params:{start: 0,limit: colNum1}});
		this.add(posSupplyChannelListGridPanel_1);
	}
});
